import { http } from '@/utils'

import type { ResType } from './shared'

// 1.Banner 接口
//  1.1 定义具体的接口类型

export type BannerItem = {
    id: number
    alt: string
    banner: string
    href: string
  }
  
type BannerRes = BannerItem[]


//   1.2 banner 接口请求列表

export function fetchBannerAPI() {
  return http.request<ResType<BannerRes>>({
    url: '/home/bannermb/',
  })
}

// 2.ProductRem 列表接口
export type HeaderItem = {
    id: number
    title: string
    caption: string
}

export type ProductItem = {
    id: number
    title: string
    caption: string
    router: string
    alt: string
    line_image: string
}

type ProductRemHeader = HeaderItem[]
export type ProductRemRes = ProductItem[]

type HeType = {
    code: string | number
    data: ProductRemRes
    head: ProductRemHeader
  }

export function fetchProductRemAPI() {
    return http.request<HeType>({
        url: '/home/recommendedlist/',
    })
}


// 3.ProductNew 列表接口
export type ProNewItem = {
    id: number
    alt: string
    default_image: string
    router: string
    title: string
  }

  type ProNewRes = ProNewItem[]

  export function fetchProNewAPI() {
    return http.request<ResType<ProNewRes>>({
      url: '/home/newproduct/',
    })
  }
  // 4.solution 列表接口
  export type Solution = {
    id: number
    title: string
    description: string
    default_image: string
    alt: string
  }
  export type SolutionHeaderItem = {
    id: number
    title: string
    caption: string
}
  export type SolutionItem = {
    id: number
    title: string
    SolutionList: Solution[]
  }

  type SolutionHeader = SolutionHeaderItem[]
  export type SolutionRes = SolutionItem[]

  type SolType = {
    code: string | number
    data: SolutionRes
    head: SolutionHeader
  }
  export function fetchSolutionAPI() {
    return http.request<SolType>({
      url: '/home/commsol/',
    })
  }